import 'dart:async';

import 'package:applications/network/base_dio.dart';
import 'package:applications/network/extra_keys.dart';
import 'package:dio/dio.dart';

import 'package:retrofit/retrofit.dart';

part 'home_client.g.dart';

@RestApi(
  baseUrl: '',
)
abstract class HomeClient {
  // factory ApiClient({ Dio? dio, String? baseUrl}) {
  //   dio ??= BaseDio.getInstance().getDio();
  //   return _ApiClient(dio, baseUrl: baseUrl);
  // }

  factory HomeClient({Dio? dio, String? baseUrl}) {
    dio ??= BaseDio.getInstance().getDio();
    return _HomeClient(dio, baseUrl: baseUrl);
  }

  @GET('/rss/topgrossingapplications/limit={limit}/json')
  @Extra({
    ExtraKeys.needToken: false,
  })
  Future<String> topgrossing({
    @CancelRequest() CancelToken? cancelToken,
    @Path('limit') int limit = 10,
  });

  /// 下載量最多的免費App
  @GET('/rss/topfreeapplications/limit={limit}/json')
  Future<String> topfree({
    @CancelRequest() CancelToken? cancelToken,
    @Path('limit') int limit = 10,
  });

  /// 获取App的评级数与评级分数
  @GET('/lookup?id={id}')
  Future<String> lookup({
    @Path('id') required String id,
  });

  // @GET('/rss/topgrossingapplications/limit={limit}/json')
  // Future<ResponseData<ApplicationBean>> topgrossingTest({
  //   @Path('limit') int limit = 10,
  // });
}
